<?php
class SetCurrentUserBehavior extends CActiveRecordBehavior {

	public $createUserIdAttribute=null;

	public function beforeSave($event) {
		if ($this->getOwner()->getIsNewRecord() && ($this->createUserIdAttribute !== null)) {
			$this->getOwner()->{$this->createUserIdAttribute} = Yii::app()->user->id;
		}
	}
}